package com.examsystem.service.impl;

import com.examsystem.dao.PaperClassMapper;
import com.examsystem.pojo.PaperClass;
import com.examsystem.service.PaperClassService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

import static com.examsystem.Const.ConstMsg.GET_PAPER_CLASS_FAIL_MSG;

/**
 * @author fire'ge
 */
@Service("paperClassServiceImpl")
public class PaperClassServiceImpl implements PaperClassService {
    @Resource
    private PaperClassMapper paperClassMapper;

    @Override
    public PaperClass queryPaperClassByUserIdAndPaperId(int paperId, int userId) {
        PaperClass paperClass = paperClassMapper.queryPaperClassByClassPaperId(paperId, userId);
        if (paperClass==null){
            throw new RuntimeException(GET_PAPER_CLASS_FAIL_MSG);
        }
        return paperClass;
    }

    @Override
    public List<PaperClass> queryAllPaperClass() {
        List<PaperClass> paperClasses = paperClassMapper.queryAllPaperClass();
        if (paperClasses==null){
            throw new RuntimeException(GET_PAPER_CLASS_FAIL_MSG);
        }
        return paperClasses;
    }

}
